#!/usr/bin/python3.8.9
# -*- coding: utf-8 -*-

# @Author  : Tina Yu
# @Time    : 2021-12-26 17:52
from appium.webdriver import WebElement
from appium.webdriver.common.mobileby import MobileBy


def scroll_then_findelement(driver, text_view) -> WebElement:
    """
    滚动后查找元素
    :param driver: driver
    :param text_view: 查找的文本
    :return: appium下的WebElement
    """
    ele = driver.find_element(MobileBy.ANDROID_UIAUTOMATOR, 'new UiScrollable(new UiSelector().scrollable(true))'
                                                            '.scrollIntoView(new UiSelector()'
                                                            f'.text("{text_view}"))')
    return ele
